/*
 * Authors: Matt Stenzel, Josh Harris, Jon Homan
 * IT 484 Fall 2008
 * */

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace MahjongTest
{
    class CustomPanel : System.Windows.Forms.Panel
    {
        private int levelColor = -1;
        private Board board;
        private int matchNum;

        public int MatchNum
        {
            get { return matchNum; }
            set { matchNum = value; }
        }

        public int LevelColor
        {
            get { return levelColor; }
            set { levelColor = value; }
        }

        public CustomPanel(Point point, int levelColor, Board board, int matchNum)
        {
            this.matchNum = matchNum;
            this.board = board;
            this.Location = point;
            this.Size = new Size(50, 70);
            this.levelColor = levelColor;

            // Create new labels to show color on outside of tiles.
            Label top = new Label();
            Label right = new Label();
            Label bottom = new Label();
            Label left = new Label();
            top.Height = 3;
            bottom.Height = 3;
            right.Height = 70;
            right.Width = 3;
            left.Height = 70;
            left.Width = 3;
            bottom.Location = new Point(0, 65);
            right.Location = new Point(45, 0);
            left.Location = new Point(0, 0);

            this.Controls.Add(top);
            this.Controls.Add(bottom);
            this.Controls.Add(right);
            this.Controls.Add(left);


            this.Click += new EventHandler(CustomPanel_Click);

            if (levelColor == 1)
            {
                this.BackColor = Color.Blue;
            }
            else if (levelColor == 2)
            {
                this.BackColor = Color.Green;
            }
            else if (levelColor == 3)
            {
                this.BackColor = Color.Orange;
            }
            else if (levelColor == 4)
            {
                this.BackColor = Color.Red;
            }
            else if (levelColor == 5)
            {
                this.BackColor = Color.Yellow;
            }
        }

        void CustomPanel_Click(object sender, EventArgs e)
        {
            // ***DEBUG***
            // Future Feature: add a part to the GUI that displays what tile is selected.
            //Console.WriteLine("Im clicked " + matchNum);

            board.checkMatchingForTiles(this);
            
            // ***DEBUG***
            //board.printBoardLayout();
        }
    }  

}
